{extend name="shared/layout" /}
{block name="title"}FORMID统计{/block}
{block name="css"}{/block}
{block name="javascript"}
    <script type="text/javascript">
        function initTable() {
            //先销毁表格
            $('#tb').bootstrapTable('destroy');
            //初始化表格,动态从服务器加载数据
            $("#tb").bootstrapTable({
                method: "Post",  //使用Post请求到服务器获取数据
                url: "{:url('formid/getstatistlist')}", //获取数据的Servlet地址
                striped: true,  //表格显示条纹
                pagination: true, //启动分页
                pageSize: 20,  //每页显示的记录数
                pageNumber: 1, //当前第几页
                pageList: [20, 50],  //记录数可选列表
                search: false,  //是否启用查询
                sortable: true, //是否启用排序
                sortOrder: "asc", //排序方式                
                sortable: true,                
                sidePagination: "server", //表示服务端请求                
                queryParamsType: "limit",
                contentType: "application/x-www-form-urlencoded",
                queryParams: function queryParams(params) {   //设置查询参数
                    var param = {
                        limit: params.limit,
                        offset: params.offset,
                        sortName: params.sort,
                        sortOrder: params.order,
                        keyword: $("input[name=keyword]").val(),
                        original_id: $("select[name=originalid]").val(),
                        sendstate: $("select[name=sendstate]").val()
                    };
                    return param;
                },
                onLoadSuccess: function () {  //加载成功时执行
                    
                },
                onLoadError: function () {  //加载失败时执行
                    layui.use(['layer'], function(){
                        layer.msg("加载数据失败", { time: 1500, icon: 2 });
                    })
                }
            });
        }
        
        $(document).ready(function () {
            //调用函数，初始化表格
            initTable();
            //当点击查询按钮的时候执行
            $("#search").bind("click", initTable);            
        });              

        function rownumber(value, row, index){
            var options = $('#tb').bootstrapTable('getOptions');            
            return options.pageSize * (options.pageNumber - 1) + index + 1;
        }    
    </script>
{/block}

{block name="content"}
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>FORMID统计</h5>
                    </div>
                    <div class="ibox-content">
                        <div class="row">          
                            <div class="col-sm-2 col-sm-offset-5">
                                <select name="sendstate" class="form-control">
                                    <option value="-1">状态</option>                                    
                                    <option value="0">未发送</option>
                                    <option value="1">发送失败</option>
                                </select>
                            </div>                  
                            <div class="col-sm-2">
                                <select name="originalid" class="form-control">
                                    <option value="">选择公众号</option>
                                    {volist name="appletlist" id="vo"}
                                    <option value="{$vo.original_id}">{$vo.name}</option>
                                    {/volist}
                                </select>
                            </div>
                            <div class="col-sm-2">
                                <div class="input-group">
                                    <span class="input-group-btn">
                                        <input type="text" placeholder="请输入关键词" class="input-sm form-control" id="keyword" name="keyword">
                                        <button type="button" class="btn btn-sm btn-primary" id="search">搜索</button>
                                    </span>
                                </div>
                            </div>
                            <span id="refresh" class="fa fa-refresh fa-spin" title="刷新" onclick="javascript:$('#tb').bootstrapTable('refresh')"></span>
                        </div>
                        <table data-toggle="table" id="tb" data-pagination="true">
                            <thead>
                                <tr>
                                    <th data-field="number" data-align="center" data-formatter="rownumber">序号</th>
                                    <th data-field="openid" data-align="center" data-sortable="true">OPENDID</th>
                                    <th data-field="name" data-align="center" data-sortable="true">微信号</th>
                                    <th data-field="num" data-align="center" data-sortable="true">FORMID数量</th>
                                </tr>
                            </thead>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
{/block}